
def legal(passwd: str):
    length = len(passwd)
    if length < 9:
        return False

    hasBig = 0
    hasSmall = 0
    hasNum = 0
    hasOther = 0
    for c in passwd:
        if 'A' <= c <= 'Z':
            hasBig = 1
        elif 'a' <= c <= 'z':
            hasSmall = 1
        elif '0' <= c <= '9':
            hasNum = 1
        elif c == ' ' or c == '\n':
            return False
        else:
            hasOther = 1
    if hasBig+hasSmall+hasNum+hasOther < 3:
        return False

    for i in range(length-1):
        substr = passwd[i:i+3]
        index = passwd.find(substr, i+3)
        if index != -1:
            return False

    return True


lines = []
try:
    while True:
        line = input()
        if line == '':
            break
        lines.append(line)
except:
    pass


for passwd in lines:
    if legal(passwd):
        print('OK')
    else:
        print('NG')
